package com.zhuiyun.educations.api.video.conmtroller;

import com.zhuiyun.educations.api.video.entity.Comment;
import com.zhuiyun.educations.api.video.entity.CommentDTO;
import com.zhuiyun.educations.api.video.service.CommentService;
import com.zhuiyun.educations.common.response.CommonResult;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName CommentController
 * @Description TODO
 * @Author 杨友朋
 * @Date 2023/7/12 11:27
 **/
@RestController
@RequestMapping("/comment")
@CrossOrigin
public class CommentController {
    @Resource
    CommentService commentService;

    /**
    * @Author 杨友朋
    * @Description TODO 分页全查
    * @Date 2023/7/12 11:28
    * @Return
    * @param commentDTO,pageRequest
    */
    @GetMapping("/selectComment")
    public CommonResult selectComment(CommentDTO commentDTO, PageRequest pageRequest){
        return CommonResult.ok(commentService.selectComment(commentDTO,pageRequest));
    }
    
    @GetMapping("/delById")
    public CommonResult delById(Integer id){
        if(id!=null){

                return CommonResult.ok(commentService.delById(id));
        }else {
            return CommonResult.ok("参数为空");
        }
        
    }
    
    @PostMapping("/insertComment")
    public CommonResult insertComment(@RequestBody Comment comment){
        if(comment!=null){
            return commentService.insertComment(comment);
        }else {
            return CommonResult.ok("参数不能为null");
        }
    }
}
